var express = require('express');
var app = express();
var proxyMiddleware = require('http-proxy-middleware')
var proxyTable = {
  '/dc-meta-server':{
    target:'http://10.6.50.113:8089',
    changeOrigin:true
  }
}
    
app.use(express.static('./dist/'));

app.get('/', function (req, res) {
  res.send('Hello World');
})
// proxy api requests
Object.keys(proxyTable).forEach(function (context) {
  var options = proxyTable[context]
  if (typeof options === 'string') {
    options = { target: options }
  }
  app.use(proxyMiddleware(options.filter || context, options))
})
var server = app.listen(8888, function () {

  var host = server.address().address
  var port = server.address().port

  console.log("应用实例，访问地址为 http://%s:%s", host, port)

})
